from flask import Blueprint, request, current_app
# from DB import db
# from models import User
# from utils import curd
# from utils.security import get_hash_pwd, token_manager
from ..utils.response import Response

user_rt = Blueprint('user', __name__)



@user_rt.get("/login")
def login():
    # req = request.json
    # username = req.get("username")
    # password = req.get("password")
    # if not username or not password:
    #     return Response.error(msg="用户名或密码是必填的")
    #
    # user = db.session.execute(db.select(User).filter_by(username=username)).scalar()
    # if not user:
    #     return Response.error(msg="用户不存在")
    # if user.password != get_hash_pwd(password, current_app):
    #     return Response.error(msg="账号密码错误")
    # token = token_manager(current_app)
    # access_token, refresh_token, access_expires, access_id = token.gen_jwt(id=user.id, username=username)
    # data = user.info
    # data.update({
    #     "access_token": access_token,
    #     "refresh_token": refresh_token,
    #     "expires": access_expires,
    #     "access_id": access_id
    # })
    return Response.success(msg="登录成功", data='1111')